﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SAP.BusinessOne.ActiveDirectory.Web
{
    public static class ExceptionExtension
    {
        public static string ToJson(this Exception source)
        {
            var error = new
            {
                Type = source.GetType().FullName,
                Message = source.Message,
                Trace = source.StackTrace
            };
            return JToken.FromObject(error).ToString();
        }
    }
}